package com.zjl.mapper;

import com.zjl.pojo.Dept;
import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * @ClassName DeptMapper
 * @Description TODO
 * @Author ZJL
 * @Date 2023/10/26 18:21
 * @Version 1.0
 **/
@Mapper
public interface DeptMapper {

    /**
     * 部门列表查询
     * @return
     */
    @Select("select * from dept")
    List<Dept> query();

    /**
     * 根据id删除部门
     * @param id
     */
    @Delete("delete from dept where id = #{id}")
    Integer deleteById(Integer id);

    /**
     * 新增部门
     * @param dept
     */
    @Insert("insert into dept(name,create_time,update_time)" +
            "values(#{name},#{createTime},#{updateTime})")
    Integer insert(Dept dept);

    /**
     * 根据id查询部门
     * @param id
     */
    @Select("select * from dept where id = #{id}")
    Dept getDeptById(Integer id);


    /**
     * 修改部门
     * @param dept
     */
    @Update("update dept set name = #{name}," +
            "update_time = #{updateTime} where id = #{id}")
    void update(Dept dept);
}
